<html>
<head><meta charset="utf-8"><title>core::ptr::addr_of(_mut) in Reference · t-lang/doc · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/237824-t-lang/doc/index.html">t-lang/doc</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/237824-t-lang/doc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20Reference.html">core::ptr::addr_of(_mut) in Reference</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="232024520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/237824-t-lang/doc/topic/core%3A%3Aptr%3A%3Aaddr_of%28_mut%29%20in%20Reference/near/232024520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/237824-t-lang/doc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20Reference.html#232024520">(Mar 26 2021 at 20:06)</a>:</h4>
<p>Given that these are the only way to make a raw pointer directly, these should be listed in the special types and traits chapter, no? (And also, rename that chapter because these are macros) Or are we considering the macros to be part of the core library and not part of the language?</p>



<a name="232068596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/237824-t-lang/doc/topic/core%3A%3Aptr%3A%3Aaddr_of%28_mut%29%20in%20Reference/near/232068596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/237824-t-lang/doc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20Reference.html#232068596">(Mar 27 2021 at 06:25)</a>:</h4>
<p>the macros aren't implementable in Rust itself, they must be done in the compiler as an intrinsic macro. Even alternative compilers would have to do it this way.</p>



<a name="232068616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/237824-t-lang/doc/topic/core%3A%3Aptr%3A%3Aaddr_of%28_mut%29%20in%20Reference/near/232068616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/237824-t-lang/doc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20Reference.html#232068616">(Mar 27 2021 at 06:25)</a>:</h4>
<p>so they're certainly "language" rather than "core library"</p>



<a name="232068660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/237824-t-lang/doc/topic/core%3A%3Aptr%3A%3Aaddr_of%28_mut%29%20in%20Reference/near/232068660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/237824-t-lang/doc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20Reference.html#232068660">(Mar 27 2021 at 06:26)</a>:</h4>
<p>even though they're accessed through a particular path rather than a global item</p>



<a name="232079043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/237824-t-lang/doc/topic/core%3A%3Aptr%3A%3Aaddr_of%28_mut%29%20in%20Reference/near/232079043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/237824-t-lang/doc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20Reference.html#232079043">(Mar 27 2021 at 09:57)</a>:</h4>
<p>Yeah, the only reason they are macros is that we weren't ready to commit to a surface syntax</p>



<a name="232079046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/237824-t-lang/doc/topic/core%3A%3Aptr%3A%3Aaddr_of%28_mut%29%20in%20Reference/near/232079046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/237824-t-lang/doc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20Reference.html#232079046">(Mar 27 2021 at 09:57)</a>:</h4>
<p>so it's a lot like <code>try!</code> in that regard</p>



<a name="232140865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/237824-t-lang/doc/topic/core%3A%3Aptr%3A%3Aaddr_of%28_mut%29%20in%20Reference/near/232140865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/237824-t-lang/doc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20Reference.html#232140865">(Mar 28 2021 at 04:30)</a>:</h4>
<p>So it should definitely be documented. But should it go in special types or should it go in the operators chapter?</p>



<a name="232140912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/237824-t-lang/doc/topic/core%3A%3Aptr%3A%3Aaddr_of%28_mut%29%20in%20Reference/near/232140912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/237824-t-lang/doc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20Reference.html#232140912">(Mar 28 2021 at 04:31)</a>:</h4>
<p>There's also a difference compared to <code>try!</code> because <code>try!</code> was just a macro. You could write it in userland. <code>addr_of!</code> gives new functionality.</p>



<a name="232141647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/237824-t-lang/doc/topic/core%3A%3Aptr%3A%3Aaddr_of%28_mut%29%20in%20Reference/near/232141647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/237824-t-lang/doc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20Reference.html#232141647">(Mar 28 2021 at 04:46)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> I'm requesting you send a PR to document the two macros in the reference. If you're willing, of course.</p>



<a name="232154191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/237824-t-lang/doc/topic/core%3A%3Aptr%3A%3Aaddr_of%28_mut%29%20in%20Reference/near/232154191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/237824-t-lang/doc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20Reference.html#232154191">(Mar 28 2021 at 09:13)</a>:</h4>
<p><span class="user-mention silent" data-user-id="296643">isHavvy</span> <a href="#narrow/stream/237824-t-lang.2Fdoc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20special.20types.20and.20traitschapter.3F/near/232140865">said</a>:</p>
<blockquote>
<p>So it should definitely be documented. But should it go in special types or should it go in the operators chapter?</p>
</blockquote>
<p>where is the <code>&amp;</code> operator documented?</p>



<a name="232154199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/237824-t-lang/doc/topic/core%3A%3Aptr%3A%3Aaddr_of%28_mut%29%20in%20Reference/near/232154199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/237824-t-lang/doc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20Reference.html#232154199">(Mar 28 2021 at 09:13)</a>:</h4>
<p><span class="user-mention silent" data-user-id="296643">isHavvy</span> <a href="#narrow/stream/237824-t-lang.2Fdoc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20special.20types.20and.20traitschapter.3F/near/232141647">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> I'm requesting you send a PR to document the two macros in the reference. If you're willing, of course.</p>
</blockquote>
<p>I can add it to my list but I probably won't get to it this week-end.</p>



<a name="232157413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/237824-t-lang/doc/topic/core%3A%3Aptr%3A%3Aaddr_of%28_mut%29%20in%20Reference/near/232157413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/237824-t-lang/doc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20Reference.html#232157413">(Mar 28 2021 at 10:17)</a>:</h4>
<p>It's documented in the expressions/operands chapter.</p>



<a name="232158123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/237824-t-lang/doc/topic/core%3A%3Aptr%3A%3Aaddr_of%28_mut%29%20in%20Reference/near/232158123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/237824-t-lang/doc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20Reference.html#232158123">(Mar 28 2021 at 10:32)</a>:</h4>
<p>That would also be the right spot for <code>addr_of!</code> then, IMO</p>



<a name="233019050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/237824-t-lang/doc/topic/core%3A%3Aptr%3A%3Aaddr_of%28_mut%29%20in%20Reference/near/233019050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/237824-t-lang/doc/topic/core.3A.3Aptr.3A.3Aaddr_of(_mut).20in.20Reference.html#233019050">(Apr 03 2021 at 17:13)</a>:</h4>
<p>Here you go: <a href="https://github.com/rust-lang/reference/pull/1001">https://github.com/rust-lang/reference/pull/1001</a><br>
(again, no need to hurry with the review)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>